package com.hashbee.util;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;

import com.yunpian.sdk.YunpianClient;
import com.yunpian.sdk.model.Result;
import com.yunpian.sdk.model.SmsSingleSend;

public class Yunpian {
	
	
	
	//发送短信API
	public static int sendSMS(String phone, String code){
	    YunpianClient clnt = new YunpianClient("3912f4616ecead80d1631a57f94a4e15").init();
		System.out.println("smscode:"+code);
		Map<String, String> param = clnt.newParam(2);
		param.put(YunpianClient.MOBILE, phone);
		param.put(YunpianClient.TEXT, "【橡拓信息】HashBee 验证码是"+code+"。有效期为5分钟，请尽快验证。");//"【橡拓信息】Hashbee 验证码是"+code+"。有效期为5分钟，请尽快验证。");
		Result<SmsSingleSend> r = clnt.sms().single_send(param);
		System.out.println(r.getCode()+";"+r.getMsg()+";"+r.getData()+";"+r.getDetail());
		clnt.close();
		return r.getCode();
	}

	public static void main(String[] args) {
//		Yunpian.sendSMS("13641892349");
	}
}
